package main.java.com.extract;

import java.util.Enumeration;

public class TextStatement extends Statement {


    @Override
    public String headerString(Customer customer) {
        return ("<H1>Rental Record for <EM>" + customer.getName() + "</EM><H1><P>");
    }

    @Override
    String eachRentalString(Rental rental) {
        return "\t" + rental.getMovie().getTitle() + "\t" + rental.getAmount() + "\n";
    }

    @Override
    String footerString(Customer customer) {
        return "Amount owed is " + customer.getTotalAmount();
    }


    public String value(Customer customer) {
        Enumeration rentals = customer.getRentals().elements();
        String result = headerString(customer);
        while (rentals.hasMoreElements()) {
            Rental each = (Rental) rentals.nextElement();
            result += "\t" + each.getMovie().getTitle() + "\t";
        }
        return result;
    }
}
